import sympy

layer_starter = lambda n: 4 * n * n - 10 * n + 7

if __name__ == '__main__':
    i = 5
    count = 8
    while True:
        t = [layer_starter(i) + j * 2 * (i - 1) for j in range(4) if sympy.isprime(layer_starter(i) + j * 2 * (i - 1))]
        count += len(t)
        if count * 10 < 4 * i - 3:
            print(2 * i - 1)
            break
        i += 1
